﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls.Interfaces;

namespace Silvermoon.Controls.Base
{
    public abstract class ToolbarBase : Control, IToolbar
    {
        private Window window;

        public override void Dispose()
        {
            ((IToolbar)this).Window = null;
            base.Dispose();
        }

        /// <summary>
        /// Gets the window that holds the toolbar.
        /// </summary>
        public Window Window { get { return window; } }

        protected virtual int OverlaySize { get { return 0; } }

        #region IToolbar Members

        Window IToolbar.Window
        {
            get { return window; }
            set
            {
                if (window != value)
                {
                    OnWindowChanging(window, value);
                    window = value;
                }
            }
        }

        protected virtual void OnWindowChanging(Window oldValue, Window newValue)
        {
        }

        int IToolbar.OverlaySize { get { return this.OverlaySize; } }

        #endregion
    }
}
